package com.tengju.user.infrastructure.repository.convert;

import com.tengju.user.domain.model.chief.ChiefClubRelation;
import com.tengju.user.domain.model.chief.ChiefClubRelationId;
import com.tengju.user.domain.model.chief.ChiefId;
import com.tengju.user.domain.model.club.ClubId;
import com.tengju.user.infrastructure.persistence.mybatis.dataobject.ChiefClubRelationDO;

public class ChiefClubRelationConvert {

    public static ChiefClubRelation convert(ChiefClubRelationDO chiefClubRelationDO) {
        if (chiefClubRelationDO == null) {
            return null;
        }
        return new ChiefClubRelation(
                new ChiefClubRelationId(chiefClubRelationDO.getId()),
                new ClubId(chiefClubRelationDO.getClubId()),
                new ChiefId(chiefClubRelationDO.getChiefId()),
                chiefClubRelationDO.getClubName()
        );
    }

    public static ChiefClubRelationDO toDo(ChiefClubRelation chiefClubRelation) {
        if (chiefClubRelation == null) {
            return null;
        }
        ChiefClubRelationDO  chiefClubRelationDO = new ChiefClubRelationDO();
        chiefClubRelationDO.setChiefId(chiefClubRelation.getChiefId().getValue());
        chiefClubRelationDO.setClubId(chiefClubRelation.getClubId().getValue());
        chiefClubRelationDO.setId(chiefClubRelation.getChiefClubRelationId().getValue());
        chiefClubRelationDO.setClubName(chiefClubRelation.getClubName());
        return chiefClubRelationDO;
    }
}
